import complex_query from '@dfeidao/atom-nodejs/db/complex-query';
import { IncomingHttpHeaders } from 'http';
import { systemid } from '../../atom/config';
interface Message {
	pn: number;
	Inventory_people_no: string;
	project_id: string;
	lnventory_name: string;
}
/* 表名	asset_inventory
标题	资产盘点
字段名称	字段标题	字段类型	字段长度	是否为空	是否主键
project_name	项目名称	string	500	√	ⅹ
inventory_people	盘点人	string	50	√	ⅹ
inventory_time	盘点时间	timestamp	50	√	ⅹ
_id	id	string	50	ⅹ	√
productid	产品id	string	50	√	ⅹ
project_id	项目编号	string	50	√	ⅹ
customer_reviews	客户签名	blob	50	√	ⅹ
record_no	记录编号	string	50	√	ⅹ
lnventory_name	盘点名称	string	100	√	ⅹ
inventory_people_no	盘点人编号	string	50	√	ⅹ */


export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const p = complex_query(action_id, session_id, systemid);
	const dt = await p
		.add_field('asset_inventory', 'Inventory_people_no', 'Inventory_people_no')
		.add_field('asset_inventory', 'lnventory_name', 'lnventory_name')
		.add_field('asset_inventory', 'project_name', 'project_name')
		.add_field('asset_inventory', 'project_id', 'project_id')
		.add_field('asset_inventory', 'record_no', 'record_no')
		.add_field('asset_inventory', 'inventory_time', 'inventory_time')
		.add_field('asset_inventory', 'Inventory_people', 'Inventory_people')
		.where_like('asset_inventory', 'project_id', "%" + message.project_id)
		.where_like('asset_inventory', 'Inventory_people_no', "%" + message.Inventory_people_no + "%")
		.where_like('asset_inventory', 'lnventory_name', "%" + message.lnventory_name + "%")
		.page(20,message.pn)
		.exec();
		const dt2 = await p
		.add_field('asset_inventory', 'Inventory_people_no', 'Inventory_people_no')
		.add_field('asset_inventory', 'lnventory_name', 'lnventory_name')
		.add_field('asset_inventory', 'project_name', 'project_name')
		.add_field('asset_inventory', 'project_id', 'project_id')
		.add_field('asset_inventory', 'record_no', 'record_no')
		.add_field('asset_inventory', 'inventory_time', 'inventory_time')
		.add_field('asset_inventory', 'Inventory_people', 'Inventory_people')
		.where_like('asset_inventory', 'project_id', "%" + message.project_id)
		.where_like('asset_inventory', 'Inventory_people_no', "%" + message.Inventory_people_no + "%")
		.where_like('asset_inventory', 'lnventory_name', "%" + message.lnventory_name + "%")
		.exec();
	return { dt,dt2 };
}
